<template>
    <div class="updateTrainPlanStuff">
	    <el-breadcrumb separator="/" class="breadcrumb-bottom">
	      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
	      <el-breadcrumb-item>专业培养方案</el-breadcrumb-item>
	      <el-breadcrumb-item>修改专业培养方案</el-breadcrumb-item>
	    </el-breadcrumb>
      <el-form :model="trainingSchema" ref="trainingSchema" label-width="100px" class="demo-ruleForm fixed-form">

        <el-form-item label="专业" prop="majorID">
          <el-select v-model="trainingSchema.majorID" placeholder="请选择专业"  class="max-width">
            <el-option
              v-for="item in majorList"
              :label="item.majorName"
              :value="item.majorID">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="修订人" prop="revised">
          <el-input v-model="trainingSchema.revised"></el-input>
        </el-form-item>
        <el-form-item label="审核人" prop="auditor">
          <el-input v-model="trainingSchema.auditor"></el-input>
        </el-form-item>
        <el-form-item label="计划文件" prop="fileID">
          <el-upload
            class="upload-demo"
            action="http://localhost:8080/TeachingMIS/trainingSchema/uploadSchema"
            :on-success="setFileID">
            <el-button size="small" type="primary">点击上传</el-button>
           	<el-input v-model="trainingSchema.fileID"></el-input>
          </el-upload>
        </el-form-item>
        <el-form-item label="创建时间" required>
          <el-form-item prop="createTime">
            <el-date-picker type="date" placeholder="选择日期" v-model="trainingSchema.createTime" style="width: 100%;"></el-date-picker>
          </el-form-item>
        </el-form-item>
        <el-form-item label="备注" prop="remark1">
          <el-input type="textarea" v-model="trainingSchema.remark1"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="onSubmit">保存</el-button>
          <el-button @click="">取消</el-button>
        </el-form-item>
      </el-form>
    </div>
</template>
<style>
</style>
<script>
    export default{
        name : 'updateTrainPlanStuff',
        data(){
            return{
                trainingSchema:{
                	trainingSchemeID:'',
                    majorID:'',
                    majorName:'',
                    revised:'',
                    auditor:'',
                    createTime:'',
                    fileID:'',
                    fileName:'',
                    fileURL:'',
                    remark1:''
                },
                majorList:[]
            }
        },
        mounted() {
          this.res();
	      this.getMajor();
	    },
        methods:{
        getMajor(){
	        this.$http.get(`http://localhost:8080/TeachingMIS/common/getMajorList`)
	          .then((res) => {
	            //console.log(res)
	            this.majorList = res.body
	          }, (err) => {
	            // 响应错误回调
	            //console.log(err)
	          })
        },
        setFileID(fileID,file){
        	this.trainingSchema.fileID=fileID;
        	alert(this.trainingSchema.fileID);
        },
        res(){
	        var trainingSchemeID = this.$route.query.trainingSchemeID;
	        this.$http.post(`http://localhost:8080/TeachingMIS/trainingSchema/getSchemaByID`, {
	          trainingSchemeID: trainingSchemeID
	        }).then((res) => {
	          // 响应成功回调
	          console.log(res.body)
	          this.trainingSchema = res.body;
	        }, (err) => {
	          // 响应错误回调
	          console.log("服务器异常！");
	        })
      	},
        onSubmit() {
            console.log("on submit");
            alert(this.trainingSchema.fileID);
            this.$http.post('http://localhost:8080/TeachingMIS/trainingSchema/updateSchema',this.trainingSchema).then((response) => {
                this.$notify({
                    title:"成功",
                    message:"修改培养计划成功",
                    type:"success"
                });
                alert("修改培养计划成功");
            }).catch(function(response){
                 alert("修改培养计划失败");
            })
        }
        }
    }
</script>
